# -*- coding: utf-8 -*-

from PyQt5.QtWidgets import *
from PyQt5.Qt import *
import sys


class QSlider_demo(QWidget):
    def __init__(self):
        super(QSlider_demo, self).__init__()
        self.setWindowTitle("QSlider 示例")

        layout = QVBoxLayout()

        self.label = QLabel("Hello An")
        self.label.setAlignment(Qt.AlignCenter)
        layout.addWidget(self.label)

        # 水平方向
        self.lider = QSlider(Qt.Horizontal)
        # 设置最小值
        self.lider.setMinimum(10)
        # 设置最大值
        self.lider.setMaximum(50)
        # 步长
        self.lider.setSingleStep(3)
        # 设置当前值
        self.lider.setValue(20)
        # 刻度位置，刻度在下方
        self.lider.setTickPosition(QSlider.TicksBelow)
        # 设置间隔
        self.lider.setTickInterval(5)

        self.lider.valueChanged.connect(self.value)
        layout.addWidget(self.lider)

        self.setLayout(layout)

    def value(self):
        print("current value:",self.lider.value())
        size = self.lider.value()
        self.label.setFont(QFont("微软雅黑",size))

if __name__ == '__main__':
    app = QApplication(sys.argv)
    lider = QSlider_demo()
    lider.show()
    sys.exit(app.exec_())